/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    General Information   ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

client/var
	Game = ""

	TotalSpins = 0

	///////////////
	TotalWager = 0
	VideoSlotsWager = 0
	BJWager = 0
	ClassicWager = 0
	VideoPokerWager = 0
	RedDogWager = 0
	///////////////
	TotalWon = 0
	VideoSlotsWon = 0
	BJWon = 0
	ClassicWon = 0
	VideoPokerWon = 0
	RedDogWon = 0

	RTP = 0

	FreeSpin = 0
	AutoSpin = FALSE

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Graphics              ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
/*
	VideoSlots_Symbol1 = 'Games/Graphics/Video Slots/Symbol1.png'
	VideoSlots_Symbol2 = 'Games/Graphics/Video Slots/Symbol2.png'
	VideoSlots_Symbol3 = 'Games/Graphics/Video Slots/Symbol3.png'
	VideoSlots_Symbol4 = 'Games/Graphics/Video Slots/Symbol4.png'
	VideoSlots_Symbol5 = 'Games/Graphics/Video Slots/Symbol5.png'
	VideoSlots_Symbol6 = 'Games/Graphics/Video Slots/Symbol6.png'
	VideoSlots_Symbol7 = 'Games/Graphics/Video Slots/Symbol7.png'
	VideoSlots_Symbol8 = 'Games/Graphics/Video Slots/Symbol8.png'
	VideoSlots_Wild = 'Games/Graphics/Video Slots/Wild.png'
	VideoSlots_Scatter = 'Games/Graphics/Video Slots/Scatter.png'

	VideoSlots_Symbol1w = 'Games/Graphics/Video Slots/Symbol1w.png'
	VideoSlots_Symbol2w = 'Games/Graphics/Video Slots/Symbol2w.png'
	VideoSlots_Symbol3w = 'Games/Graphics/Video Slots/Symbol3w.png'
	VideoSlots_Symbol4w = 'Games/Graphics/Video Slots/Symbol4w.png'
	VideoSlots_Symbol5w = 'Games/Graphics/Video Slots/Symbol5w.png'
	VideoSlots_Symbol6w = 'Games/Graphics/Video Slots/Symbol6w.png'
	VideoSlots_Symbol7w = 'Games/Graphics/Video Slots/Symbol7w.png'
	VideoSlots_Symbol8w = 'Games/Graphics/Video Slots/Symbol8w.png'
	VideoSlots_Wildw = 'Games/Graphics/Video Slots/Wildw.png'
	VideoSlots_Scatterw = 'Games/Graphics/Video Slots/Scatterw.png'
*/
	VideoSlots_Symbol1 = "#400000"
	VideoSlots_Symbol2 = "#400000"
	VideoSlots_Symbol3 = "#400000"
	VideoSlots_Symbol4 = "#004000"
	VideoSlots_Symbol5 = "#004000"
	VideoSlots_Symbol6 = "#004000"
	VideoSlots_Symbol7 = "#000040"
	VideoSlots_Symbol8 = "#000040"
	VideoSlots_Wild = "#434400"
	VideoSlots_Scatter = "#441600"

	VideoSlots_Symbol1w = "#FF4040"
	VideoSlots_Symbol2w = "#FF4040"
	VideoSlots_Symbol3w = "#FF4040"
	VideoSlots_Symbol4w = "#00C000"
	VideoSlots_Symbol5w = "#00C000"
	VideoSlots_Symbol6w = "#00C000"
	VideoSlots_Symbol7w = "#4040FF"
	VideoSlots_Symbol8w = "#4040FF"
	VideoSlots_Wildw = "#C0C000"
	VideoSlots_Scatterw = "#FF6519"

	RedDog_Normal = "#800000"
	RedDog_Light = "#C00000"

	H2 = 'Games/Graphics/Cards/Hearts/2.png'
	H3 = 'Games/Graphics/Cards/Hearts/3.png'
	H4 = 'Games/Graphics/Cards/Hearts/4.png'
	H5 = 'Games/Graphics/Cards/Hearts/5.png'
	H6 = 'Games/Graphics/Cards/Hearts/6.png'
	H7 = 'Games/Graphics/Cards/Hearts/7.png'
	H8 = 'Games/Graphics/Cards/Hearts/8.png'
	H9 = 'Games/Graphics/Cards/Hearts/9.png'
	H10 = 'Games/Graphics/Cards/Hearts/10.png'
	H11 = 'Games/Graphics/Cards/Hearts/11.png'
	H12 = 'Games/Graphics/Cards/Hearts/12.png'
	H13 = 'Games/Graphics/Cards/Hearts/13.png'
	H14 = 'Games/Graphics/Cards/Hearts/14.png'

	D2 = 'Games/Graphics/Cards/Diamonds/2.png'
	D3 = 'Games/Graphics/Cards/Diamonds/3.png'
	D4 = 'Games/Graphics/Cards/Diamonds/4.png'
	D5 = 'Games/Graphics/Cards/Diamonds/5.png'
	D6 = 'Games/Graphics/Cards/Diamonds/6.png'
	D7 = 'Games/Graphics/Cards/Diamonds/7.png'
	D8 = 'Games/Graphics/Cards/Diamonds/8.png'
	D9 = 'Games/Graphics/Cards/Diamonds/9.png'
	D10 = 'Games/Graphics/Cards/Diamonds/10.png'
	D11 = 'Games/Graphics/Cards/Diamonds/11.png'
	D12 = 'Games/Graphics/Cards/Diamonds/12.png'
	D13 = 'Games/Graphics/Cards/Diamonds/13.png'
	D14 = 'Games/Graphics/Cards/Diamonds/14.png'

	S2 = 'Games/Graphics/Cards/Spades/2.png'
	S3 = 'Games/Graphics/Cards/Spades/3.png'
	S4 = 'Games/Graphics/Cards/Spades/4.png'
	S5 = 'Games/Graphics/Cards/Spades/5.png'
	S6 = 'Games/Graphics/Cards/Spades/6.png'
	S7 = 'Games/Graphics/Cards/Spades/7.png'
	S8 = 'Games/Graphics/Cards/Spades/8.png'
	S9 = 'Games/Graphics/Cards/Spades/9.png'
	S10 = 'Games/Graphics/Cards/Spades/10.png'
	S11 = 'Games/Graphics/Cards/Spades/11.png'
	S12 = 'Games/Graphics/Cards/Spades/12.png'
	S13 = 'Games/Graphics/Cards/Spades/13.png'
	S14 = 'Games/Graphics/Cards/Spades/14.png'

	C2 = 'Games/Graphics/Cards/Clubs/2.png'
	C3 = 'Games/Graphics/Cards/Clubs/3.png'
	C4 = 'Games/Graphics/Cards/Clubs/4.png'
	C5 = 'Games/Graphics/Cards/Clubs/5.png'
	C6 = 'Games/Graphics/Cards/Clubs/6.png'
	C7 = 'Games/Graphics/Cards/Clubs/7.png'
	C8 = 'Games/Graphics/Cards/Clubs/8.png'
	C9 = 'Games/Graphics/Cards/Clubs/9.png'
	C10 = 'Games/Graphics/Cards/Clubs/10.png'
	C11 = 'Games/Graphics/Cards/Clubs/11.png'
	C12 = 'Games/Graphics/Cards/Clubs/12.png'
	C13 = 'Games/Graphics/Cards/Clubs/13.png'
	C14 = 'Games/Graphics/Cards/Clubs/14.png'

	BACK = 'Games/Graphics/Cards/back.png'



/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Games Menu Select     ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

client/verb

	GamesMainStart()
		set hidden = 1
		if(Game == "") StartGames()
		else CloseGames()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Games Menu Select     ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	GamesVideoSlots()
		set hidden = 1
		StartVideoSlots()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Classic Slots         ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	GamesClassicSlots()
		set hidden = 1
		StartClassicSlots()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Black Jack            ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	GamesBlackJack()
		set hidden = 1
		StartBlackJack()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Red Dog               ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	GamesRedDog()
		set hidden = 1
		StartRedDog()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Video Poker           ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	GamesVideoPoker()
		set hidden = 1
		StartVideoPoker()

//////////////////////////////////////////////////////////////////////
// Admin Verb for giving people money
//////////////////////////////////////////////////////////////////////

	Grant(var/key as text, var/credits as num)
		set hidden = 1
		if(!(src.ckey in Admins)) return
		var/client/person = findTarget(key)
		if(person)
			if(credits <= 0)
				System_UserMessage(src,"You can't give a person 0 credits.")
			else
				System_UserMessage(person,"[credits] credits have been bestowed upon you.")
				OutputLog(GREEN,"[src] granted [person] [credits] free credits.")
				person.Credits+=credits
				person.SaveCasino()
		else
			System_UserMessage(src,"That person isn't logged in, or doesn't exist.")

client/proc

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Universal             ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	UpdateCredits()
		if(Game == "Video Slots") winset(src,"Games_VideoSlots.balance","text=\"[num2text(Credits,12)]\"")
		if(Game == "Red Dog") winset(src,"Games_RedDog.balance","text=\"[num2text(Credits,12)]\"")

	StartGames()
		Game = " Main Menu"
		winset(src,"Games_Container","size=800x600;is-visible=true;title=\"Games Menu\"")
		winset(src,"Games_Container.child","left=Games_Main")

	CloseGames()
		Game = ""
		winset(src,"Games_Container","is-visible=false")
		AutoSpin = FALSE
		RDClose()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Video Slots           ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	StartVideoSlots()
		//if(Game != " Main Menu") return
		Game = "Video Slots"
		winset(src,"Games_Container.child","left=Games_VideoSlots")
		winset(src,"Games_Container","title=\"Video Slots\"")
		UpdateCredits()
		VideoInit()

	GamesLoadVideoSlotInfo()
		winset(src,"Games_VideoSlotInfo","is-visible=true")

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Classic Slots         ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	StartClassicSlots()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Black Jack            ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	StartBlackJack()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Video Poker           ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	StartVideoPoker()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Red Dog               ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	StartRedDog()
		//if(Game != " Main Menu") return
		Game = "Red Dog"
		winset(src,"Games_Container.child","left=Games_RedDog")
		winset(src,"Games_Container","title=\"Red Dog\"")
		UpdateCredits()
		RDInit()

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Called by the profile ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	Give(var/key as text, var/credits as num)
		var/client/person = findTarget(key)
		var/GID = 0
		var/RID = 0
		if(person)
			GID = ReturnKeyID(src.key)
			RID = ReturnKeyID(person.key)
		if(GID == RID) return
		if(person)
			if(credits <= 0)
				System_UserMessage(src,"You can't give a person 0 credits.")
			else if(src.Credits >= credits)
				System_UserMessage(src,"[credits] credits have been transfered to [person].")
				System_UserMessage(person,"[src] has transfered [credits] credits to you.")
				OutputLog(GREEN,"[src] transfered [credits] credits to [person].")
				src.Credits-=credits
				person.Credits+=credits
				src.SaveCasino()
				person.SaveCasino()
			else
				System_UserMessage(src,"You don't have enough credits.")
		else
			System_UserMessage(src,"That person isn't logged in, or doesn't exist.")


/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Credits Generator     ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/


	GenerateCredits()
		LoadCasino()
		if(src.Credits < 500)
			if(rand(1,20) == 1)
				src.Credits += 500
				var/message = pick("Here's $5, go try your luck at some games.","If I give you $5, can you turn it into 10?","An extra $5 should keep you busy, go play something.")
				System_UserMessage(src, message)
				SaveCasino()
		spawn(20*MINUTE) GenerateCredits()



/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
///    Card Image Return     ///
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

	CardImage(var/cardnum as num, var/suit as text)
		if(suit == "Hearts")
			if(cardnum == 2) return H2
			if(cardnum == 3) return H3
			if(cardnum == 4) return H4
			if(cardnum == 5) return H5
			if(cardnum == 6) return H6
			if(cardnum == 7) return H7
			if(cardnum == 8) return H8
			if(cardnum == 9) return H9
			if(cardnum == 10) return H10
			if(cardnum == 11) return H11
			if(cardnum == 12) return H12
			if(cardnum == 13) return H13
			if(cardnum == 14) return H14
		else if(suit == "Spades")
			if(cardnum == 2) return S2
			if(cardnum == 3) return S3
			if(cardnum == 4) return S4
			if(cardnum == 5) return S5
			if(cardnum == 6) return S6
			if(cardnum == 7) return S7
			if(cardnum == 8) return S8
			if(cardnum == 9) return S9
			if(cardnum == 10) return S10
			if(cardnum == 11) return S11
			if(cardnum == 12) return S12
			if(cardnum == 13) return S13
			if(cardnum == 14) return S14
		else if(suit == "Clubs")
			if(cardnum == 2) return C2
			if(cardnum == 3) return C3
			if(cardnum == 4) return C4
			if(cardnum == 5) return C5
			if(cardnum == 6) return C6
			if(cardnum == 7) return C7
			if(cardnum == 8) return C8
			if(cardnum == 9) return C9
			if(cardnum == 10) return C10
			if(cardnum == 11) return C11
			if(cardnum == 12) return C12
			if(cardnum == 13) return C13
			if(cardnum == 14) return C14
		else if(suit == "Diamonds")
			if(cardnum == 2) return D2
			if(cardnum == 3) return D3
			if(cardnum == 4) return D4
			if(cardnum == 5) return D5
			if(cardnum == 6) return D6
			if(cardnum == 7) return D7
			if(cardnum == 8) return D8
			if(cardnum == 9) return D9
			if(cardnum == 10) return D10
			if(cardnum == 11) return D11
			if(cardnum == 12) return D12
			if(cardnum == 13) return D13
			if(cardnum == 14) return D14